import javax.swing.*;
import java.io.*;
import java.util.*;

public class Exit implements Entity, Serializable {

	private Location destination;
	private String direction;
	private boolean Locked;
	private Entity Key;
	
	protected boolean isBed = false;
	
	protected String DisplayName;
	protected String Name;
	protected String Description;
	protected String Orientation;
	protected ArrayList<Entity> Inventory = new ArrayList<Entity>();
	protected boolean CanBePickedUp = false;
	protected String Why = "You can't pick this up!\n\n";
	protected int value;
	protected double Weight;
	
	protected int Gold;
	
	private boolean isVisible;
	private boolean forSale = false;
	private boolean Lockable;
	
	public Exit(String a, String b, String d, Location f) {
		Orientation = a;
		DisplayName = b;
		Name = DisplayName.substring(DisplayName.lastIndexOf(" ") + 1);
		Description = d;
		destination = f;
		Locked = false;
		isVisible = true;
		Weight = 100.0;
		Gold = 0;
		Lockable = true;
	}
	
	public void setGold(int a) {
		Gold = a;
	}
	
	public double getWeight() {
		return Weight;
	}
	
	public void isLockable(boolean a) {
		Lockable = a;
	}
	
	public boolean isLockable() {
		return Lockable;
	}
	
	public void forSale(boolean a) {
		forSale = a;
	}
	
	public boolean isForSale() {
		return forSale;
	}
	
	public void Display(JTextArea y) {
		y.append("Leading " + Orientation + " is " + DisplayName + ". " + "\n");
	}
	
	public Location getDestination() {
		return destination;
	}
	
	public String getDirection() {
		return direction;
	}
	
	public boolean isLocked() {
		return Locked;
	}
	
	public void NeedsKey(Entity a) {
		Key = a;
	}
	
	public void modifyGold(int a) {
		Gold = Gold + a;
	}
	
	public int getGold() {
		return Gold;
	}
	
	public void StartsLocked(boolean a) {
		Locked = a;
	}
	
	public Entity getKey() {
		return Key;
	}
	
	public void unlock() {
		Locked = false;
	}
	
	public void lock() {
		Locked = true;
	}
	
	public void addEntity(Entity a) {
		Inventory.add(a);
	}
	
	public ArrayList<Entity> getInventory() {
		return Inventory;
	}
	
	public void removeObject(Entity a) {
		Inventory.remove(a);
	}
	
	public void Describe(JTextArea y) {
		y.append(Description + "." + "\n");	
	}
	
	public String getOrientation() {
		return Orientation;
	}
	
	public void setOrientation(String a) {
		Orientation = a;
	}
	
	public String getDisplayName(){
		return DisplayName;
	}
	
	public String getName() {
		return Name;
	}
	
	public String getDescription() {
		return Description;
	}
	
	public void Use(Player a, String b, JTextArea y, JTextField x) {		
	}
	
	public boolean TestCanBePickedUp() {
		return CanBePickedUp;
	}
	
	public void CantBePickedUp(String b) {
		CanBePickedUp = false;
		Why = b;		
	}
	
	public String CanBePickedUp_Why() {
		return Why;
	}
	
	public void printInventory(JTextArea y) {
		y.append("Searching the " + DisplayName + " you find the following items:\n\n");
		for (Entity a : Inventory) {
			y.append(a.getName());
		}
	}
	
	public void setVisible(boolean a) {
		isVisible = a;
	}
	
	public boolean isVisible() {
		return isVisible;
	}
	
	public void setContentsVisible(boolean a) {
		for (Entity b : Inventory) {
			b.setVisible(true);
		}
	}
	
	public int getValue() {
		return value;
	}
	
	public void setValue(int a) {
		value = a;
	}
	
	public boolean isBed() {
		return isBed;
	}
	
	public void isBed(boolean a) {
		isBed = a;
	}
	
}
